<template>
    <view>
		<!-- <view class="img2">lkajsflkfjs</view> -->
		<!-- <gz-image-rotate ref="gzImageRotate" @success="success"></gz-image-rotate> -->
    
		<image class="img2" src="../../static/images/fontDirection.png"></image>
		<view>
			<htz-signature class="sign" @sumbit="sumbit"  @fail="fail" cid="ceshi1"></htz-signature>
		</view>
    </view>
</template>
<script>
    import htzSignature from '@/components/htz-signature/htz-signature.vue'
	// import gzImageRotate from '@/components/gz-image-rotate/gz-image-rotate.vue'
    
    export default {
        data() {
            return {
				
            }
        },
        components: {
            htzSignature,
			// gzImageRotate,
        },
        mounted() {
            this.$nextTick(function() {
            });
        },
		onLoad(option) {
			console.log('onLoad option -------------- ', option);
			this.option = option;
			
			if(0){
				uni.showModal({
					title: '注意事项',
					content: '为了报名成功, \r\n需要横向的手写电子签名! \r\n签名前请将手机先横过来.',
					// confirmText: "否", 
					showCancel: false,
					
					cancelText: "是",
					success: function(res) {
						console.log('~~~~~~~~~~~ success ', res);
						return
					},
					fail: function(res) {
						console.log('!!!!!!!!!!!!! fail', res);
					}
				});
			}
		},
		
        methods: {  
			// success(e){
			// 	console.log('******* e.tempFilePath', e.tempFilePath)
			// 	// uni.saveImageToPhotosAlbum({
			// 	//  filePath:e.tempFilePath
			// 	// })
			// },
            sumbit(res){
                console.log('sumbit',res);
                try {
					/* 返回调用页面并把图片URL传递过去 */
					let pages = getCurrentPages();
					let prevPage = pages[pages.length - 2]; 
					let key = this.option.key;
					if(!key)
						key = 'aaaaaaaaaaaa';
					var dc = {[key]: res.tempFilePath};
					// console.log('dc ~~~~~~~ ', dc);
					// this.$refs.gzImageRotate.start(res.tempFilePath, 3);
					
					// uni.canvasToTempFilePath(object, component)
					
					console.log('~~~~~~~~ canvasToTempFilePath ~~~~~~~~~~~~~')
					// uni.canvasToTempFilePath({
					// 	fileType: "jpg",
					// 	canvasId: 'canvasLineA',
					// 	success: function(res) {
					// 		// 在H5平台下，tempFilePath 为 base64
					// 		console.log('tempFilePath ===== ', res.tempFilePath)
							
					// 		uni.saveImageToPhotosAlbum({
					// 			filePath: res.tempFilePath,
					// 			success: function() {
					// 				uni.showToast({
					// 					icon: 'none',
					// 					position: 'bottom',
					// 					title: "图片已下载至【图库】，请打开【图库】查看", // res.tempFilePath
					// 				});
					// 			}
					// 		});
					// 	}
					// })
					
					
					if(prevPage)
						prevPage.setData(dc);
					
                    uni.navigateBack();
                } catch (e) {
                    // error
					console.log('catch e ~~~~~~~~~', e)
                }
            },
            fail(err){
                console.log('fail --------', err)
            },
			
			exportImg() {
				uni.canvasToTempFilePath({
					fileType: "jpg",
					canvasId: 'canvasLineA',
					success: function(res) {
						// 在H5平台下，tempFilePath 为 base64
						console.log(res.tempFilePath)
		
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: function() {
								uni.showToast({
									icon: 'none',
									position: 'bottom',
									title: "图片已下载至【图库】，请打开【图库】查看", // res.tempFilePath
								});
							}
						});
					}
				})
			}
        }
    }
</script>

<style lang="scss">  
  .img2{
	height: 120upx;
  	z-index:2;
	// opacity: 0.5;
	// transform:rotate(90deg);
  }
</style> 
  